﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutoTestingFramework.Utilities.DataProviders
{
    public class DataProvider : IDataReader
    {
        private IDataReader _objDataProvider;

        public string TableName
        {
            get
            {
                return _objDataProvider.TableName;
            }
            set
            {
                _objDataProvider.TableName = value;
            }
        }

        public bool IsConnectionOpen
        {
            get { return _objDataProvider.IsConnectionOpen; }
        }

        public uint Seek
        {
            get
            {
                return _objDataProvider.Seek;
            }
            set
            {
                _objDataProvider.Seek = value;
            }
        }

        public void Open()
        {
            _objDataProvider.Open();
        }

        public void Close()
        {
            _objDataProvider.Close();
        }

        public bool Next()
        {
            return _objDataProvider.Next();
        }

        public string[] GetPresentRowData()
        {
            return _objDataProvider.GetPresentRowData();
        }

        public string GetCellData(int Column, int Row)
        {
            return _objDataProvider.GetCellData(Column, Row);
        }

        public string GetCellData(string TestCaseId, int Column, int RowSeek)
        {
            return _objDataProvider.GetCellData(TestCaseId, Column, RowSeek);
        }

        public DataProvider(DataProviderConfig config)
        {
            if (config.DataSourceType == DataSourceType.CSV)
            {

            }
            else if (config.DataSourceType == DataSourceType.Excel)
            {
                _objDataProvider = new ExcelHelper(config.ConnectionString, config.TableName);
            }
        }
        public System.Data.DataTable GetDataInDataSet(int ColumnBeginIndex, int ColumnEndIndex, int BeginRowIndex, int EndRowIndex)
        {
            return _objDataProvider.GetDataInDataSet(ColumnBeginIndex, ColumnEndIndex, BeginRowIndex, EndRowIndex);
        }
    }
}
